﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Benchmarks.ListCreation
{
    public class ListCreationSuite : BenchmarkSuite
    {
        public ListCreationSuite() : 
            base( "CollectionCreation", 
                new ListCreationBenchmark( "List 10",  10, "CollectionCreation" ),
                new ListCreationBenchmark( "List 100",  100, "CollectionCreation" ),
            new DictionaryCreationBenchmark( "Dict 10", 10, "CollectionCreation" ),
            new DictionaryCreationBenchmark( "Dict 100", 100, "CollectionCreation" )
            ) {}
    }
    public class ListCreationBenchmark : Benchmark {
        private String m_Category;
        public override string Category { get { return m_Category; } }
        private String m_Name;
        public override string Name { get { return m_Name; } }
        private int m_Size;
        public ListCreationBenchmark( string name, int size, string category ) {
            m_Name = name;
            m_Size = size;
            m_Category = category;
        }

        public override void StartTrials() {  }
        public override void RunOverheadTest( int num_iterations ) {  }

        public static List< int > current; 
        public override void RunTrial( int num_iterations ) {
            for (int trial_count = 0 ; trial_count < num_iterations; trial_count++) {

                List< int > list = new List< int >(  );
                for( int i = 0 ; i < m_Size ; i++ ) list.Add( i );
                current = list;
            }

        }
    }
    public class DictionaryCreationBenchmark : Benchmark
    {
        private String m_Category;
        public override string Category { get { return m_Category; } }
        private String m_Name;
        public override string Name { get { return m_Name; } }
        private int m_Size;
        public DictionaryCreationBenchmark(string name, int size, string category)
        {
            m_Name = name;
            m_Size = size;
            m_Category = category;
        }

        public override void StartTrials() { }
        public override void RunOverheadTest(int num_iterations) { }
        
        public static Dictionary< int, int > current;

        public override void RunTrial(int num_iterations)
        {
            for (int trial_count = 0 ; trial_count < num_iterations; trial_count++) {
                current = new Dictionary< int, int >();
                for( int i = 0 ; i < m_Size ; i++ ) current.Add( i, i );
            }
        }
    }
}
